<?php
/**
 * 这里是登录操作
 * 
 * @author jerry
 * @version $Id$
 * @package model
 *
 */

class Info extends Controller
{
	/**
	 * 解析函数
	 *
	 */
	function __construct()
	{
		parent::__construct();
		$this->loadModel('info_model');
	}

	function showDate()
	{
		$page = !empty($this->in_var['page']) ? $this->in_var['page'] : 1;
		$num  = !empty($this->in_var['num'])  ? $this->in_var['num']  : $this->sys_info['PageNum'];

		$sort = $this->in_var['sort'] ? $this->in_var['sort'] : '-Id';
		
		$order = $this->info_model->getOrder($sort);
		
		$result_list      = $this->info_model->getList('*',$order,$page,$num);
		$result_page_info = $this->info_model->getPageInfo('?c=info&d=showDate&page={Page}&sort='
		. $this->in_var['sort']
		. $parm);

		
		$this->tpl->assign('ResultPageInfo',$result_page_info);
		$this->tpl->assign("ResultList", $result_list);
		
		$this->tpl->display('info_list.html');    //指定模板
	}

	
	function  add()
	{
		if($this->in_var['request_method'] == 'post')
		{
			$state = $this->info_model->add();
			
			if($state)
			{
				show_message('添加成功',$_SERVER['HTTP_REFERER']);
			}
			else
			{
				show_message('失败鸟。。请返回检查',$_SERVER['HTTP_REFERER']);
			}
		}
		
		$category_list = $this->info_model->getCategoryForSelect(0,$this->in_var['CategoryID']);
		$area_list = $this->info_model->getAreaForSelect(0,$this->in_var['AreaID']);

		$this->tpl->assign('AreaForSelect',$area_list);
		$this->tpl->assign('CategoryForSelect',$category_list);
		$this->tpl->display('info_add.html');    //指定模板
	}

	function  edit()
	{
		if($this->in_var['request_method'] == 'post')
		{
			$state = $this->info_model->edit();
			
			if($state)
			{
				show_message('编辑成功',$this->in_var['referer']);
			}
			else
			{
				show_message('失败鸟。。请返回检查',$_SERVER['HTTP_REFERER']);
			}
		}
		
		$result_info = $this->info_model->getInfo($this->in_var['id']);
		
		$category_list = $this->info_model->getCategoryForSelect(0,$this->in_var['CategoryID']);
		$area_list = $this->info_model->getAreaForSelect(0,$this->in_var['AreaID']);

		$this->tpl->assign('AreaForSelect',$area_list);
		$this->tpl->assign('CategoryForSelect',$category_list);
		$this->tpl->assign('referer',$_SERVER['HTTP_REFERER']);
		
		$this->tpl->assign('ResultInfo',$result_info);
		$this->tpl->display('info_edit.html');    //指定模板
	}
	
	function pass()
	{
			$state = $this->info_model->pass($this->in_var['state']);
			
			if($state)
			{
				show_message('状态更改成功',$_SERVER['HTTP_REFERER']);
			}
			else
			{
				show_message('失败鸟。。请返回检查',$_SERVER['HTTP_REFERER']);
			}
	}
	
	function  delete()
	{
			$state = $this->info_model->delete($this->in_var['id']);
			
			if($state)
			{
				show_message('已经成功删除了',$_SERVER['HTTP_REFERER']);
			}
			else
			{
				show_message('失败鸟。。请返回检查',$_SERVER['HTTP_REFERER']);
			}
	}


}